package com.binyouwei.designpatterns.creation_type.builder;

/**
 * @author 宾有为
 * @date 2024/6/28 20:14
 * @link https://blog.csdn.net/baidu_41616022?type=blog
 * @describe：
 **/
public class BuilderStudent {
    private String name;
    private int age;

    public BuilderStudent(Builder builder) {
        this.name = builder.name;
    }

    public static class Builder{
        private String name;
        private int age = 0;

        public Builder(String name){
            this.name = name;
        }

        public Builder setName(String name) {
            this.name = name;
            return this;
        }

        public Builder setAge(int age) {
            this.age = age;
            return this;
        }

        public BuilderStudent build(){
            return new BuilderStudent(this);
        }
    }

    @Override
    public String toString() {
        return "name："+name+" age："+age;
    }
}
